package r25.engine;

import r25.character.ICharacter;
import r25.room.IRoom;

public class Event implements IEvent {
	private final EVENT type;
	private final ICharacter character;
	private final IRoom room;
	private boolean valid;
	private GameStateTimeStamp timeStamp;

	public Event(EVENT type, IRoom room, ICharacter character) {
		super();
		this.type = type;
		this.room = room;
		this.character = character;
		this.setValid(type.isDelayedCheck());
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("[ " + valid);
		builder.append(" ");
		builder.append(type);
		builder.append(", ");
		if (character != null) {
			builder.append("character:");
			builder.append(character);
			builder.append(", ");
		}
		if (room != null) {
			builder.append("in Room ");
			builder.append(room);
			builder.append(", ");
		}
		builder.append(" @ ");
		builder.append(timeStamp);
		builder.append("]");
		return builder.toString();
	}

	@Override
	public EVENT getType() {
		return type;
	}

	@Override
	public ICharacter getCharacter() {
		return character;
	}

	@Override
	public IRoom getRoom() {
		return room;
	}

	@Override
	public GameStateTimeStamp getTimeStamp() {
		return timeStamp;
	}

	@Override
	public void setTimeStamp(GameStateTimeStamp timeStamp) {
		this.timeStamp = timeStamp;
	}

	@Override
	public boolean isValid() {
		return valid;
	}

	@Override
	public void setValid(boolean valid) {
		this.valid = valid;
	}
}
